﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SubsidyApp.Models;

namespace SubsidyApp.Models
{
    public class LocationsRepository
    {
        public IQueryable<other_dist> GetAllDists()
        {
            return BasesDescription.db.other_dists;
        }

        public IQueryable<other_dist_address> GetAllAddress()
        {
            return BasesDescription.db.other_dist_addresses;
        }

        public IQueryable<other_dist_address> GetDistAddress(int id)
        {
            return from address in BasesDescription.db.other_dist_addresses
                   where address.dist_id == id
                   select address;
        }

        public string GetDistTitle(int id)
        {
            return BasesDescription.db.other_dists.Single(x => x.id == id).dist_title;
        }

        public other_dist GetDist(int id)
        {
            return BasesDescription.db.other_dists.Single(x => x.id == id);
        }

        public other_dist_address GetAddress(int id)
        {
            return BasesDescription.db.other_dist_addresses.Single(x => x.id == id);
        }
    }
}